<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>京城男人帮---确认订单信息</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/home/css/head.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/home/css/footer.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/home/css/go.css" />
	<script src="__PUBLIC__/home/js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
	<style>
		table.hovertable {
		    font-family: verdana,arial,sans-serif;
		    font-size:11px;
		    color:#333333;
		    border-width: 1px;
		    border-color: #999999;
		    border-collapse: collapse;
		    width: 60%;
		}
		table.hovertable th {
		    background-color:#c3dde0;
		    border-width: 1px;
		    padding: 8px;
		    border-style: solid;
		    border-color: #a9c6c9;
		}
		table.hovertable tr {
		    background-color:#d4e3e5;
		 	text-align: center;
		}
		table.hovertable td {
		    border-width: 1px;
		    padding: 2 8px;
		    border-style: solid;
		    border-color: #a9c6c9;
		}
		.tr-line a{
			color: red;
			font-size: 12px;
	    }
	</style>
</head>
<body>
	<div class="header">
		<!--顶部导航-->
        {include file="public/top_nav"}
        <!--顶部导航end-->
		<!--图片-->
		<div class="full_sc order_bottom">
			<div class="w1200 header_conter ">
				<div class="h_c_logo">
					<a href="{:url('home/index/index')}">
						<img src="__PUBLIC__/home/image/logo.png"  width="102px" height="98px" />
					</a>
				</div>
				<div class="h_c_right">
					<div class="order_Status os_oredr"></div>
				</div>
			</div>
		</div>
		<!--end-->
	</div>
	
	<div class="public_b">
		<form action="" method="post">
			<div class="w1200">
				<div class="h2">确认订单信息</div>
				<!--商品-->
				<div class="o_o_part o_o_part3">
					<h2 class="part_h2">1&nbsp;商品清单<a class="a_return_car" href="{:url('home/cart/submit')}"> &lt; 返回购物车</a></h2>
					<div class="oder_shop">
						<!--shoptitle-->
						<div class="shop_tit">
							<div class="cart_checkbox">
								<span>商品名称</span>
							</div>
							<div class="column cart_standard">规格</div>
							<div class="column t_price">单价(元)</div>
							<div class="column t_quantity">数量</div>
							<div class="column t_sum">小计(元)</div>
						</div>
						<!--shoptitle-->
						<!--shoplist-->
						<div class="item_list">
						<?php if (!empty($cartData)){ ?>
							<?php foreach ($cartData as $key => $value){ ?>
							<div class="item_form">
								<div class="cell p_checkbox"></div>
								<div class="cell p_goods" width="605px">
									<div class="goods_item">
										<div class="p_imgs">
											<a target="_blank" href="">
												<img src="__PUBLIC__/<?php echo $value['g_img'] ?>" alt="<?php echo $value['g_name'] ?>" width="60px" height="60px"></a>
										</div>
										<div class="item_msg" width="530px">
											<div class="p_border_bottom">
												<div class="p_name">
													<a target="_blank" href="http://www.happigo.com/item-0-174196.html"><?php echo $value['g_name'] ?></a>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="cell p_standard " style="padding-left: 10px;color:#A8A8A8;font-size:12px;">
									<?php echo str_replace(";","<br>",$value['gui_name']); ?>
								</div>
								<div class="cell p_price p_border_bottom" style="width:105px;">
									<p class="p_prices2"><?php echo $value['g_price_dj'] ?></p>
								</div>
								<div class="cell p_quantity">
									<div class="quantity_form p_border_bottom">x<?php echo $value['s_num'] ?></div>
								</div>
								<div class="cell p_sum p_border_bottom">
									<strong class="g_price"><?php echo $value['g_price'] ?></strong>
								</div>
							</div>
							<?php } ?>
						<?php } ?>
						</div>
						<!--shoplist-->
							<!--优惠卷-->
							<!-- <div class="border_b">
								<div class="user_jf_yhj">
									<div class="user_jf_yhj_t">
										<b>-</b>使用积分和优惠券
									</div>
								</div>
								<div class="use_jf_yhj_c">
									<div class="order_items">
										<div class="yhj_show">使用优惠券：</div>
										<select name="">
	                                        <option value="0">----不使用----</option>
	                                        <option value="5285942">5(188元新人套券-5元)</option>
	                                        <option value="5285943">10(188元新人套券-10元)</option>
	                                        <option value="5285944">20(188元新人套券-20元)</option>
	                                   </select>
									</div>
								</div>
							</div> -->
							<!--优惠卷-->
							
							<!--发票-->
							<!-- <div class="ask_bill">
								<p>
									<label class="lab_bill">
	                                    <input name="fapiao" value="1" checked="" type="checkbox">
	                                    <span>索要发票</span>
	                               </label>
								</p>
								<ul class="ask_bill_ul">
									<li fapiao_type="电子发票" class="on">电子发票<b></b></li>
									<li fapiao_type="普通发票">普通发票<b></b></li>
								</ul>
								<p class="bill_c">
									发票抬头：
									<label class="lab_bill p_r_30">
	                                    <input name="invoice" value="1" checked="checked" type="radio"><span>个人</span>
	                                </label>
									<label class="lab_bill">
	                                    <input name="invoice" value="2" type="radio"><span>单位</span>
	                                </label>
								</p>
								<div class="bill_c bill_unit" style="display:none;">
									<p>
										<span class="bill_c_name">单位名称：  </span>
										<input class="bill_itxt" name="fapiao_danwei" type="text">
									</p>
									<p class="bill_tips">温馨提示：您填写的内容将被系统自动打印到发票上，请勿填写发票抬头无关的信息.</p>
								</div>
							</div> -->
							<!--发票-->
						<!--结算-->
						<div class="yhxx_box">
							<ul class="yhxx_list">
								<li>
									<div class="yhxx_tit">商品总额<span class="yhxx_money">￥<span class="sum_price">199</span> </span>
									</div>
								</li>
								<me id="paypromotion"></me>
								<me id="paypromotion_info"></me>
								<!-- <li>
									<div class="yhxx_tit">优惠券<span class="yhxx_money"><span class="s_jian">-</span>￥<span id="voucher_price">0</span> </span>
									</div>
								</li> -->
								<li class="margin_top10">
									<div class="yhxx_tit">本单应付 <span class="yhxx_money">￥<span class="s_sum s_order_money">0</span> </span>
									</div>
								</li>
							</ul>
						</div>
						<!--结算-->
					</div>
				</div>
				<!--商品-->
				<!--地址选择-->
				<div class="o_o_content">
					<!--支付方式-->
					<div class="o_o_part o_o_part2">
						<h2 class="part_h2">2 支付方式</h2>
						<div class="pay_type">
							<ul>
								<li class="on" payment_code="online">在线支付<b></b></li>
								<li payment_code="offline">货到付款<b></b></li>
							</ul>
						</div>
					</div>
					<!--支付方式-->
					<h2 class="part_h2">
						3 地址选择
						<!-- <span class="addr_errtips">
							<i class="icon_err"></i>
							您好！此地址不在该商品配送区域范围内，请选择其他收货地址！
						</span> -->
					</h2>
					<div class="addr_list" id="addr_list">
						<ul>
							<li class="addr_new">
								<div class="btn_new_addr" nc_type="addr" id="add_addr">添加新地址</div>
							</li>
							<li>
								<div class="btn_new_addr" nc_type="addr" id="add_ou" style="display:none;">收起</div>
							</li>
						</ul>
					</div>
					<!-- 新添加地址 -->
					<div class="new_addr" style="display: none;">
						<div class="ncc-form-default">
							<!-- <input value="buy" name="act" type="hidden">
							<input value="add_addr" name="op" type="hidden">
							<input name="form_submit" value="ok" type="hidden"> -->
							<dl>
								<dt><i class="required">*</i>收货人姓名：</dt>
								<dd>
									<input class="text w100" name="ad_name" maxlength="20" id="ad_name" value="" type="text">
								</dd>
							</dl>
							<dl>
								<dt> <i class="required">*</i>手机号码：</dt>
								<dd>
									<input class="text w200" name="ad_tel" id="ad_tel" maxlength="15" value="" type="text">
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>所在地区：</dt>
								
								<dd>
									<div id="region">
										<!-- 地址联动 -->
										<span class="label_n"><span class="c_red">*</span>所在地区：</span>
										<select class="city" name="country[]" id="statename">
											<option value="0">请选择地区</option>
											<?php foreach ($areaData as $key => $value): ?>
												<option value="<?php echo $value['area_id'] ?>"><?php echo $value['area_name'] ?></option>
											<?php endforeach ?>
										</select>
										<div class="addr_msg">
											<span id="error_statename"></span>
										</div>
										<!-- 地址联动 -->
									</div>
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>详细地址：</dt>
								<dd>
									<input class="text w500" name="ad_address" id="ad_address" maxlength="80" value="" type="text">
									<p class="hint">请填写真实地址，不需要重复填写所在地区</p>
								</dd>
							</dl>
							<dl>
								<dt> <i class="required">*</i>邮编：</dt>
								<dd>
									<input class="text w200" name="ad_code" id="ad_code" maxlength="15" value="" type="text">
								</dd>
							</dl>
							<div class="btn_item">
								<a href="javascript:;" id="addresssubmit" class="btn_addaddr">确定</a>　
								<!-- <a href="javascript:;" class="btn_addaddr" onclick="submitAddList();">返回</a> -->
							</div>
						</div>
					</div>
					<!-- 新添加地址 -->
					<?php if (!empty($addressData)){ ?>
						<div class="new_addr1">
							<!-- Table goes in the document BODY -->
							<table class="hovertable">
								<tr>
								    <th>收货人</th>
									<th>收货人地址</th>
									<th>手机</th>
									<th>邮编</th>
									<th>操作</th>
								</tr>
								<?php foreach ($addressData as $key => $value){ ?>
									<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';" ad_id="<?php echo $value['ad_id'] ?>">
										<td><?php echo $value['ad_name'] ?></td>
										<td><?php echo $value['ad_address_xq'] ?></td>
										<td><?php echo $value['ad_tel'] ?></td>
										<td><?php echo $value['ad_code'] ?></td>
										<td class="tr-line">
										<?php if ($value['ad_is_default']==1){ ?>
											<span style="color:#8e8e8e;font-size:12px;" id="ymr">已设为默认</span><br>
											<a href="#" title="" class="del">删除</a><br>
										<?php }else{ ?>
											<a href="#" title="" id="mr">设为默认</a><br>
											<a href="#" title="" class="del">删除</a><br>
										<?php } ?>
										</td>
									</tr>
								<?php } ?>
							</table>
						</div>
					<?php }else{ ?>
						<div class="new_addr">
							<div class="ncc-form-default">
								<i class="required" style="padding-left: 100px;color: red;">没有地址，请先添加地址！！</i>
							</div>
						</div>
					<?php } ?>
				</div>
				<!--地址选择end-->
				<!-- 买家留言 -->
				<div class="btnsure_bg">
					<textarea name="o_remark" id="o_remark"></textarea>
				</div>
				<!-- 买家留言 -->
				<!--结算-->
				<div class="btnsure_bg">
					<div class="sureorder">
						<div class="jine">应付总额：<span class="fwxh_30">￥</span><span class="span_m s_order_money">199</span></div>
						<a class="un_btn_sure" id="btn_sure" href="javascript:void(0);">提交订单</a>
					</div>
				</div>
				<!--结算-->
			</div>
		</form>
	</div>

   	<!--底部公用-->
    {include file="public/footer"}
    <!--底部end-->
</body>
</html>
<script>
	$(document).on("click","#btn_sure",function(){
		var o_type = $(".pay_type ul li[class=on]").text();
		var sum_price = $(".span_m").text();
		var o_remark = $("#o_remark").val();
		$.ajax({
			url:"{:url('home/cart/orderAdd')}",
			type:"post",
			dataType:"json",
			data:{o_type:o_type,sum_price:sum_price,o_remark:o_remark},
			success:function(res){
				if(res==3){
					alert('添加失败，请刷新后重试！');
					window.location.href = "{:url('home/cart/submitpath')}";
				}else if(res==2){
					alert("请重新确认！");
					window.location.href = "{:url('home/cart/submitpath')}";
				}else if(res==1){
					alert("登录已过期，请重新登录");
					window.location.href = "{:url('home/user/login')}";
				}else{
					window.location.href = "{:url('home/cart/truesubmit')}";
				}
			}
		})
	})
</script>
<script>
	$(function(){
		// 计算总额
		getTotal();
		function getTotal() {
			var sum_price =  0;
			$(".g_price").each(function () {
				var g_price  =  $(this).text();
				sum_price += Number(g_price);
			})
			$(".sum_price").text(sum_price);
			$(".s_sum").text(sum_price);
			$(".span_m").text(sum_price);
		}
	})
</script>
<script>
	// 删除地址
	$(document).on("click",".del",function(){
		var ad_id = $(this).parents("tr").attr("ad_id");
		var bool = confirm("是否删除该地址");
		if(bool==true){
			$.ajax({
				url:"newPathDel",
				data:{ad_id:ad_id},
				dataType:"json",
				success:function(res){
					if(res == 0){
						alert("删除成功");
						window.location.href = "{:url('home/user/newPath')}";
					}else if(res == 1){
						alert("请重新登录");
						window.location.href = "{:url('home/user/login')}";
					}else{
						alert("请刷新后删除");
					}
				}
			})
		}
	})
	// 地址添加
	$(document).on("click","#addresssubmit",function(){
		var ad_name = $("#ad_name").val();
		var ad_tel = $("#ad_tel").val();
		var city = new Array();
		$(".city").each(function (i) {
			city[i] = $(this).val();
		})
		var ad_address = $("#ad_address").val();
		var ad_code = $("#ad_code").val();
		$.ajax({
			url:"{:url('home/user/newPathAdd')}",
			type:"post",
			dataType:"json",
			data:{ad_name:ad_name,ad_tel:ad_tel,country:city,ad_address:ad_address,ad_code:ad_code},
			success:function(res){
				if(res==4){
					alert('该地址已存在，请勿重复添加！');
					window.location.href = "{:url('home/cart/submitpath')}";
				}else if(res==3){
					alert('添加地址上限，请先删除后再添加！');
					window.location.href = "{:url('home/cart/submitpath')}";
				}else if(res==2){
					alert("请重新填写");
					window.location.href = "{:url('home/cart/submitpath')}";
				}else if(res==1){
					alert("登录已过期，请重新登录");
					window.location.href = "{:url('home/user/login')}";
				}else{
					window.location.href = "{:url('home/cart/submitpath')}";
				}
			}
		})
	})
	// 设置默认
	$(document).on("click","#mr",function () {
		var ad_id = $(this).parents('tr').attr('ad_id');
		var _this  = $(this);
		$.ajax({
			url:"{:url('home/user/newPathMr')}",
			data:{ad_id:ad_id},
			dataType:"json",
			success:function(res){
				alert("设置成功");
				window.location.href = "{:url('home/cart/submitpath')}";
			}
		})
	})
	// 支付方式样式
	$(function(){
		//添加一个点击事件  支付方式
		$(".pay_type ul li").click(function(){
			var n = $(this).index();
			//切换颜色 
			$(".pay_type ul li").eq(n).addClass("on").siblings().removeClass("on");
		})
		//添加一个点击事件  发票
		$(".ask_bill ul li").click(function(){
			var n = $(this).index();
			//切换颜色
			$(".ask_bill ul li").eq(n).addClass("on").siblings().removeClass("on");
		})
	})
	// 绑定地区联动事件
	$(document).on("change",".city",function(){
		var area_id = $(this).val();
		var _this = $(this);
		$.ajax({
			url:"submitpath",
			data:{area_id:area_id},
			dataType:"json",
			success:function(res){
				if(area_id>0){
					if(res.areaData.length>0){
						var select = '<select class="city" name="country[]" id="statename">';
						select +='<option value="0">请选择地区</option>';
						$.each(res.areaData,function(i,v){
							select += '<option value="'+v.area_id+'">'+v.area_name+'</option>';
						})
						select +='</select>';
						_this.nextAll('.region select').remove();
						_this.after(select);
					}
				}else{
					_this.nextAll('.region select').remove();
				}
			}
		})
	})
</script>
<script>
	$(document).on("click","#add_addr",function(){
		$("#add_ou").show();
		$(".new_addr").show();
	})
	$(document).on("click","#add_ou",function(){
		$("#add_ou").hide();
		$(".new_addr").hide();
	})
</script>